// Achievement by G3X / GeXeH - Enjoy
// Version 1.0

// Achievement: Listen to 1 hour of microphone discussion.

local Value = achievements.GetValue( "Chatter Box", "total", 0 )

local target = 3600
local function Update()

	if (Value != target) then
		// print("Check Started.\n")
		local ply = LocalPlayer()

		if (!ValidEntity( ply )) then return end
		
		local Speaking = false
		for k,v in pairs(player.GetAll()) do
			if v:IsSpeaking() then
				Speaking = true
			end
		end
		
		if ( Speaking == true ) then
			// print("Player is talking.\n")
			Value = math.Clamp( Value + 1, 0, target )
			achievements.SetValue( "Chatter Box", "total", Value )
			achievements.Update( "Chatter Box", Value / target, achievements.FormatTime( Value, "h:m:s" ) )
		else
			// print("Player is not talking.\n")
		end

		// print("Check Ended.\n")
	
	else
		timer.Destroy("Achievement.ChatterBox")
	end

end

timer.Create("Achievement.ChatterBox", 1, 0, Update)

achievements.Register( "Chatter Box", "Listen to 1 hour of microphone discussion.", "achievements/chatterbox", Value / target, achievements.FormatTime( Value, "h:m:s" ) )